//
//  HomeViewController.swift
//  Wallet
//
//  Created by Julian on 2022/5/7.
//

import UIKit
import RxSwift

class HomeViewController: UIViewController {
    
    let viewModel = WalletViewModel(with: WalletRepository(walletSession: HttpClient()))
    let bag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupBindings()

        // 获取数据
        viewModel.requestData()
        
    }
}

extension HomeViewController {
    func setupBindings() {
        // 切换币种
        AppSettings.shared.currency
            .subscribe { [weak self] _ in
                self?.viewModel.requestData()
            }.disposed(by: bag)
    }
}
